

#include "stdafx.h"
#include "Mutex.h"

namespace StdTools
{
	namespace Threads
	{
		Mutex::Mutex(void)
		{
#ifdef WIN
			InitializeCriticalSection(&m_mutex);
#else
			pthread_mutex_init(&m_mutex,0);
#endif
		}


		Mutex::~Mutex(void)
		{
#ifdef WIN
			DeleteCriticalSection(&m_mutex);
#else
			pthread_mutex_destroy(&m_mutex);
#endif
		}

		void Mutex::lock()
		{
#ifdef WIN
			EnterCriticalSection(&m_mutex);
#else
			pthread_mutex_lock(&m_mutex);
#endif
		}

		void Mutex::unlock()
		{
#ifdef WIN
			LeaveCriticalSection(&m_mutex);
#else
			pthread_mutex_unlock(&m_mutex);
#endif
		}
	}
}